package 力扣日常刷题.木22二月.第01天206;

import 力扣日常刷题.TreeNode;

/**
 * @author 帅小伙
 * @date 2022/2/6
 * @description
 */
public class Demo11JZ对称的二叉树 {


    public boolean isSymmetric(TreeNode root) {
        if(root==null){
            return true;
        }
        return isSymmetric(root,root);
    }


    public boolean isSymmetric(TreeNode left,TreeNode right) {
        if(left==null && right == null) return true;
        if(left==null|| right == null) return false;
        if(left.val != right.val) return false;
        return isSymmetric(left.left,right.right) && isSymmetric(left.right,right.left);
    }

}
